home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-07-12 | 5.8 KB | 157 lines | [TEXT/GEOL] |
- Item 1497777 3-July-89 10:27
-
- From: D2086 Efficient Field Svc, C Faith, PRT
-
- To: MACAPP.TECH$ MACAPP Tech
-
- cc: FRIEDRICH1 Friedrich, Steve
-
- Sub: Control Dim ?S from CIS, LONG!
-
- Here is another message that leaves me perplexed:
-
- ********************
- I'm having problems with TControl.DimState.
-
- I have customized a button, TMyButton, in a TDialogView. I am trying to alter
- the "Dim" method to dim the adornment ring as well as the button itself. When
- the button should be dimmed I call (myButton).DimState.
-
- DimState calls DrawContents which eventually calls Draw which then calls Dim.
- I have overridden Dim.
-
- The problem is that DimState, although called for my customized button, gets
- back onto the default chain when it calls DrawContents, so the default
- (TControl) Draw is called for the redraw.
-
- If I override all three methods: DimState, Draw, and Dim for my customized
- button then it works... provided I write out the entire procedure for
- DimState. In other words I must write:
-
- PROCEDURE TMyButton.DimState (state,
- redraw: BOOLEAN); OVERRIDE;
- BEGIN
- IF state <> fDimmed THEN
- BEGIN
- fDimmed := state;
- IF redraw THEN
- DrawContents;
- END;
- END;
-
- This is an exact duplicate of TControl.DimState, but if I do it then
- DrawContents calls MyButton.Draw and MyButton.Dim.
-
- If I just write
-
- PROCEDURE TMyButton.DimState (state,
- redraw: BOOLEAN); OVERRIDE;
- BEGIN
- INHRITED DimState (state, redraw);
- END;
-
- then the default TControl.Draw and TControl.Dim are called.
-
- This smells like a bug. The reference to my instance is being lost.
- To: John Jeppson 76174,2007 (X)
-
- How frustrating!
-
- After forcing TMyButton.DimState to call TMyButton.Draw by completely
- duplicating TControl.DimState I now find that I cannot use TMyButton.Dim after
- all.
-
- Why.. because TCtlMgr.Draw (superClass of TButton) draws controls only by
- calling the Control Manager traps. Its superClass method TControl.Draw is
- NEVER called, and only TControl.Draw calls Dim. So you can override the Dim
- method for a customized Button, and that customized Dim method exists, but is
- NEVER called by anybody.
-
- Is this inheritance???
-
- -John Jeppson
- ***************
- John is doing this in attempt to disable and dim a default button whenever
- there is no text in his TEditText item.
-
- Another related question that is of a more general nature is:
-
- 1) What is the best way to get the button to dim (assume that dim is handled
- easily)? Do you do it from the TEditText doIdle method? DoKeyCommand method?
- the TDialogView.PoseModally method?
-
- I suggested that John OVERRIDE TEditText.DoMenuCommand and DoKeyCommand and
- check to see if the editText has changed to ''. He replied:
- **************
- >The trouble with overriding TEditText.DoMenu/KeyCommand is that the
- >added capabilities are executed BEFORE rather than after the INHERITED
- >action.
- >
- > FUNCTION TMyEditText.DoKeyCommand(params);
- > BEGIN
- > DoKeyCommand := INHERITED DoKeyCommand(params);
- >
- > DoAddedCapability;
- > END;
- >
- >The INHERITED feature doesn't happen until this function returns, so
- >DoAddedCapability always remains one keypress "behind" the user's
- >expectations.
-
- and said he OVERRODE the PoseModally method of TDailogView to check the status
- of the fEditText field every time. I replied.
-
- Which left me confused! Am I missing something or is he, I replied:
- ***********
- I am not sure exactly what problem you are having with INHERITED DoKeyCommand.
-
- Under your DoKeyCommand method (which should say OVERRIDE at the end) the
- INHERITED capability is called before the added capability. This is probably
- what you want, but you say that "The INHERITED feature doesn't happen until
- this function returns" The INHERITED feature happens at whatever point you
- call INHERITED. If you made this statement because this appeared to be the
- case then I think there is some other problem.
-
- Your DoKeyCommand function should give DoAddedCapability a look at the finished
- product, i.e. the results of the last keypress. This is what I would assume to
- be exactly what you want.
-
- In general,
-
- 1) You can call INHERITED before DoAddedCapability.
-
- 2) You can call INHERITED after DoAddedCapability.
-
- 3) You can call INHERITED only If you have not taken care of the function.
- This is what TEditText.DoKeyCommand does, it calls INHERITED only if the
- keypress was not in its character set.
-
- There are instances when you want to do each of these.
-
- The problem I see with your solution is not that it won't work but that it is
- too specific. Your solution works only for modal dialogs. You would have to
- implement an entirely different method for modeless dialogs, (actually windows
- really) they would get events from gApplication PollEvent and I do not
- recommend OVERRIDING that method, it would be very messy to do what you want.
-
- If you implemented the capability as a function of the TEditText and
- TDialogView you could change your dialog to modeless at will.
-
- You would have to OVERRIDE TEditText.DoKeyCommand and TEditText.DoMenuCommand.
- Also I suggest that a good way to handle the dimming etc. is to have the
- TTEditText merely give the TDialogView a chance to look at its contents,
- calling a new method TMyDialogView.EditTextChanged(theText,theEditText)
- whenever the contents had in fact changed. The TDialogView.EditTextChanged
- method could then do whatever was appropriate based on the change. This would
- also allow you to use these same objects later on do do something slightly
- different, and you could use them in modeless dialogs as well.
- ************
- And that is where it stands right now. Has anyone done this before? What did
- you do?
-
- regards,
-
- Curtis Faith
-
-
-